package org.lanqiao.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.myUtils.Myutils;
import org.lanqiao.service.FactoryService;

public class LastSevelet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取学生的这门课的信息
		int las=Myutils.getInt(request.getParameter("las"));
		if(las==0){
			//获取需要的课程id和学生信息
			String cousid=request.getParameter("uid");
			String stuName=(String) request.getSession().getAttribute("username");
			FactoryService.getUserInfoManageService().deleteStuCourse(cousid,stuName);
			//重新查询数据
			List stucourse = FactoryService.getUserInfoManageService().getStuCoIn(stuName);

			request.getSession().setAttribute("stucourse", stucourse);
			
			List ess = FactoryService.getUserInfoManageService().getStuCou(stuName);

			request.getSession().setAttribute("StuCourSel", ess);
			
			request.getRequestDispatcher("logined/stuLoginedInfo/StuCourse.jsp").forward(request, response);
		}else{
			String strCid=request.getParameter("uid");
			FactoryService.getUserInfoManageService().deleteTeaCouse(strCid);
			request.getRequestDispatcher("TeaSelCoSevelet?sel=2").forward(request, response);
		}
	}
	

}
